package com.example.hp.qingyi.company.fragment.adapter;

import android.content.Context;
import android.content.Intent;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.example.hp.qingyi.R;
import com.example.hp.qingyi.company.fragment.bean.Message;
import com.example.hp.qingyi.company.fragment.fragment.OneFragment;

import java.util.List;

public class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.ViewHolder>{
    private List<Message.DataBean> list;
    private Context context;

    public MessageAdapter(List<Message.DataBean> list, Context context) {
        this.list = list;
        this.context = context;
    }
    @NonNull
    @Override
    public MessageAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

        View view= LayoutInflater.from(context).inflate(R.layout.item_onefragment,null);
        ViewHolder holder=new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull MessageAdapter.ViewHolder holder, final int position) {
        //  Toast.makeText(context, list.get(position).getImage(), Toast.LENGTH_SHORT).show();
//        Glide.with(context).load(list.get(position).getImage()).into(holder.message_iv);
        holder.message_iv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(context,OneFragment.class);
                intent.putExtra("1", (Parcelable) list.get(position).getUser());
                intent.putExtra("2",list.get(position).getCompany_id());
                intent.putExtra("3",list.get(position).getTime());
                context.startActivity(intent);
            }
        });
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        private ImageView message_iv;
        public ViewHolder(View itemView) {
            super(itemView);
        }
    }
}

